let dbConfig = require('../utils/dbConfig')

saveChat=async(req,res)=>{
  let {sender,receiver,content,time}=req.body
  let sql='insert into chat_history(sender,receiver,content,time) values (?,?,?,?)'
  let sqlArr=[sender,receiver,content,(new Date()).valueOf()]
  let result=await dbConfig.SySqlConnect(sql,sqlArr)
  if(result.affectedRows===1){
    res.send({
      'code':200,
    })
  }else{
    res.send({
      'code':400
    })
  }
}

module.exports={
  saveChat
}